home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
BASIC
/
3064.ZIP
/
123WRITE.ZIP
/
123DEMO2.BAS
next >
Wrap
BASIC Source File
|
1990-11-15
|
61KB
|
1,800 lines
DEFINT A-Z
'123DEMO2.BAS a demonstration program for the 123-Write version 2.0
'spreadsheet file generation library.
'Sept 1990
'This program really doesn't do much of anything, I wrote it as a
'test bed of all the routines in 123-Write. The resulting worksheet
'file will be written to the current directory, unless you specify
'a full path spec at the prompt.
'BASIC:
DECLARE FUNCTION Rand% (lowerbound%, upperbound%)
DECLARE SUB ColFeed ()
DECLARE SUB Page1 ()
DECLARE SUB Page2 ()
DECLARE SUB Page3 ()
DECLARE SUB Page4 ()
DECLARE SUB Page5 ()
DECLARE SUB Page6 ()
DECLARE SUB Page7 ()
DECLARE SUB Page8 ()
DECLARE SUB Page9 ()
DECLARE SUB Page10 ()
DECLARE SUB Page11 ()
DECLARE SUB Page12 ()
DECLARE SUB Page13 ()
DECLARE SUB Page14 ()
DECLARE SUB Page15 ()
DECLARE SUB Page16 ()
DECLARE SUB Page17 ()
DECLARE SUB Page18 ()
DECLARE SUB Page19 ()
DECLARE SUB Page20 ()
DECLARE SUB WriteCol (count%)
DECLARE SUB WriteRanges ()
'123-Write include file: 123W20.BI
'Declares for all the 123-Write Routines.
DECLARE FUNCTION lCol% (col$)
DECLARE SUB lBoolean (col1%, row1%, col2%, row2%, operation%)
DECLARE SUB lCellFunction (dSeg%, dOfs%)
DECLARE SUB lCellMath (col1%, row1%, col2%, row2%, oper%)
DECLARE SUB lClose
DECLARE SUB lColFunction (startRow%, endRow%, oper%)
DECLARE SUB lConstMath (col%, row%, constVal#, oper%)
DECLARE SUB lDate (dat$)
DECLARE SUB lDown (count%)
DECLARE SUB lFileAppend (filename$, ecode%)
DECLARE SUB lFileOpen (filename$, errCode%)
DECLARE SUB lGetLoc (whatCol%, whatRow%)
DECLARE SUB lGlobal (item%, switch%)
DECLARE SUB lHideCol (col%, writeFlag%)
DECLARE SUB lLeft (count%)
DECLARE SUB lLineFeed
DECLARE SUB lLink (fileSpecRange$)
DECLARE SUB lMultiCellMath (dSeg%, dOfs%)
DECLARE SUB lPrintBorders (rulc%, rulr%, rlrc%, rlrr%, culc%, culr%, clrc%, clrr%)
DECLARE SUB lPrintMargins (lm%, rm%, tm%, bm%, pageLen%)
DECLARE SUB lPrintRange (ulc%, ulr%, lrc%, lrr%)
DECLARE SUB lPrintSetup (setup$)
DECLARE SUB lPrintTitle (title$, header%)
DECLARE SUB lRange (rangeName$, ulc%, ulr%, lrc%, lrr%)
DECLARE SUB lRight (count%)
DECLARE SUB lRowFunction (startCol%, endCol%, oper%)
DECLARE SUB lSetCellForm (formatCode%, decimals%)
DECLARE SUB lSetCols (colWidths%())
DECLARE SUB lSetCol (col%, colWidth%)
DECLARE SUB lSetDateForm (format%, protect%)
DECLARE SUB lSetLoc (newCol%, newRow%)
DECLARE SUB lSetStrForm (formatCode%)
DECLARE SUB lSetTimeForm (format%, protect%)
DECLARE SUB lSortKey (primry%, ulc%, ulr%, lrc%, lrr%, ascnd%)
DECLARE SUB lSortRange (ulc%, ulr%, lrc%, lrr%)
DECLARE SUB lTime (timeStr$)
DECLARE SUB lTimeNow
DECLARE SUB lToday
DECLARE SUB lUp (count%)
DECLARE SUB lWriteErr
DECLARE SUB lWriteInt (integerVal%, errCode%)
DECLARE SUB lWriteNum (doubleVal#, errCode%)
DECLARE SUB lWriteStr (dat$, errCode%)
'==================================================================
'
' Some frequently used co-ordinates might be handy. I'm mixing
' CONSTs and variables for testing purposes only.
'
'==================================================================
CONST Page1Col = 0 'The top left corner of page 1, cell A1
CONST Page1Row = 0
CONST Page2Col = 8 'Cell I1, the top left corner of page 2
CONST Page2Row = 0
CONST Page5Col = 0 'Cell A41, the top left corner of page 5
CONST Page5Row = 40
CONST Page6Col = 0 'Cell A61, the top left corner of page 6
CONST Page6Row = 60
CONST Page7Col = 8 'Cell I21, the top left corner of page 7
CONST Page7Row = 20
CONST Page8Col = 8 'Cell I41, the top left corner of page 8
CONST Page8Row = 40
CONST Page9Col = 0 'Cell A81, the top left corner of page 9
CONST Page9Row = 80
CONST Page10Col = 0 'Cell A100, the top left corner of page 10
CONST Page10Row = 100
CONST Page11Col = 8 'Cell I61, the top left corner of page 11
CONST Page11Row = 60
CONST Page12Col = 8 'Cell I81, the top left corner of page 12
CONST Page12Row = 80
CONST Page13Col = 0 'Cell A121, the top left corner of page 13
CONST Page13Row = 120
CONST Page14Col = 15 'Cell P21, the top left corner of page 14
CONST Page14Row = 20
CONST Page15Col = 15 'Cell P41, the top left corner of page 15
CONST Page15Row = 40
CONST Page16Col = 15 'Cell P61, the top left corner of page 16
CONST Page16Row = 60
CONST Page17Col = 15 'Cell P81, the top left corner of page 17
CONST Page17Row = 80
CONST Page18Col = 15 'Cell P101, the top left corner of page 18
CONST Page18Row = 100
CONST Page19Col = 15 'Cell P121, the top left corner of page 19
CONST Page19Row = 120
CONST Page20Col = 8 'Cell I101, the top left corner of page 19
CONST Page20Row = 100
CONST fixed = 1 'These are cell format equates, it's easier
CONST currcy = 3 'to read (fixed,2) than (1,2) I think.
CONST percent = 4
CONST comma = 5
CONST special = 6 'A hidden cell format is in the special category
CONST hidden = 6 'so these two equates will kill 2 birds...
TYPE FunctionCallType 'This guy can be used for any?? @function
fCode AS INTEGER 'call. I type'd it out to the maximum number
col1 AS INTEGER 'of elements that any of the Lotus @functions
row1 AS INTEGER 'will need. I think. We'll find out if I'm
col2 AS INTEGER 'right on page 5, so stay tuned.
row2 AS INTEGER
col3 AS INTEGER
row3 AS INTEGER
col4 AS INTEGER
row4 AS INTEGER
col5 AS INTEGER
row5 AS INTEGER
END TYPE
'A BASIC 7.0+ version of the above would look like:
'
'TYPE ColRowType
' col as INTEGER
' row as INTEGER
'END TYPE
'
'TYPE FunctionCallType
' fCode AS INTEGER
' coOrds(1 to 5) as ColRowType
'END TYPE
TYPE MultiMathType
col AS INTEGER
row AS INTEGER
opr AS INTEGER
END TYPE
DIM SHARED f AS FunctionCallType
DIM SHARED lVersion AS INTEGER
DIM SHARED errCode AS INTEGER
ON ERROR GOTO ErrorTrap
RANDOMIZE (TIMER) 'Just to vary things a little....
'==================================================================
'
' First step, get a file name, and open the spreadsheet file.
' If an extension is not supplied with the filename, 123-Write
' will use the "WKS" extension.
'
'==================================================================
KEY 1, "DEMO.WKS" + CHR$(13) 'I've run this so many times, it's easier
KEY 2, "DEMO.WK1" + CHR$(13) 'to hit 1 key for the same file over and
CLS 'over!
PRINT "123-Write version 2.0 demonstration."
PRINT "The filename you supply for the spreadsheet can be a complete"
PRINT "path spec. If you don't supply an extension, WKS will be used."
PRINT
PRINT "If the file you specify already exists, it will be overwritten"
PRINT "by this demo."
PRINT
INPUT "File name to create: ", fileSpec$
IF fileSpec$ = "" THEN END
PRINT
PRINT "Create a Lotus release 2.0+ compatible spreadsheet? (Y/N)"
PRINT "If you hit N, Lotus 1a (and compatibles) functions only"
PRINT "will be used."
DO
z$ = UCASE$(INKEY$)
LOOP UNTIL z$ = "Y" OR z$ = "N" 'The lVersion variable
'will dictate 2.0+ files
lVersion = (z$ = "Y")
CALL lFileOpen(fileSpec$, errCode) 'The error trap set above checks
IF errCode THEN ERROR 255 'for 255, indicating an error
'return from 123-Write
CALL WriteRanges 'See the documentation for an
CALL Page1 'explanation of the need to write
CALL Page2 'range names early.
CALL Page3
CALL Page4
CALL Page5
CALL Page6
CALL Page7
CALL Page8
CALL Page9
CALL Page10
CALL Page11
CALL Page12
CALL Page13
CALL Page14
CALL Page15
CALL Page16
CALL lClose 'Closing the file at this point
'to illustrate the File Append
CALL lFileAppend(fileSpec$, errCode) 'routine.
IF errCode THEN ERROR 255
CALL Page17
CALL Page18
CALL Page19
CALL Page20
CALL lClose
END
ErrorTrap:
IF ERR = 255 THEN
PRINT
PRINT "An error was returned by 123-Write."
PRINT "Error code:"; errCode
PRINT
CALL lClose
ELSE
PRINT
PRINT "An error was returned by BASIC."
PRINT "Error code:"; ERR
PRINT
CALL lClose
END IF
END
'==================================================================
'
' This section of data statements is used to write the intro on
' the first page of the spreadsheet.
'
'==================================================================
Page1Data:
DATA "123-Write version 2 demo worksheet Page 1"
DATA " "
DATA " This spreadsheet was written as a demonstration of the routines"
DATA "available in 123-Write version 2.0. The entire spreadsheet was"
DATA "written from within BASIC."
DATA " "
DATA "There are a number of ranges, all named PAGE_? that show different"
DATA "features of the routines in 123-Write. You can use the: F5 [GOTO]"
DATA "key, then the F3 key to select an area of interest.
DATA " "
DATA "Page 1 This page, which shows the String write ability."
DATA " 2 Shows the cell display options that are available."
DATA " 3 123-Write Date & Time routines, & their formats."
DATA " 4 Boolean comparisons and operators. "
DATA " 5 General, Logarithmic & Trigonometric @ Functions."
DATA " 6 Statistical and Database Statistical @ Functions."
DATA " 7 Financial and Accounting @ Functions."
DATA " 8 Logical and error testing @ Functions."
DATA " 9 Special range and miscellaneous @ Functions. "
DATA " 10 MORE options!"
Page2Data:
DATA "Illustration of cell formatting possibilites."
DATA "Fixed"
DATA "Scient"
DATA "Currency"
DATA "Percent"
DATA "Comma"
DATA "+ / -"
DATA "General"
DATA "Date 1"
DATA "Date 2"
DATA "Date 3"
DATA "Text"
DATA "Hidden"
DATA "Time 1"
DATA "Time 2"
DATA "Date 4"
DATA "Date 5"
DATA "Time 3"
DATA "Time 4"
Page3Data:
DATA "123-Write default date, time format:"
DATA " Date, Time format 1:"
DATA " Date, Time format 2:"
DATA " Date, Time format 3:"
DATA " Date, Time format 4:"
DATA " Date only format 5:"
Page5Data:
'The @Function data below is laid out in:
' 123-Write @Function code #,
' string function descriptor,
' then col, row numbers (varies by "Page" being written) and then
' a flag, either 0 or -1 to tell the demo program whether the particular
' @function is 2.0+ compatible. (-1 = 2.0+ only)
DATA 03,"@ABS",3,42,0,0,0
DATA 04,"@INT",3,42,0,0,0
DATA 17,"@MOD",1,42,2,42,0
DATA 23,"@RAND",0,0,0,0,0
DATA 33,"@ROUND",3,42,2,42,0
DATA 05,"@SQRT",1,44,0,0,0
DATA 16,"@EXP",1,47,0,0,0
DATA 07,"@LN",1,47,0,0,0
DATA 06,"@LOG",1,47,0,0,0
DATA 08,"@PI",1,47,0,0,0
DATA 09,"@SIN",1,47,0,0,0
DATA 10,"@COS",1,47,0,0,0
DATA 11,"@TAN",1,47,0,0,0
DATA 15,"@ACOS",1,47,0,0,0
DATA 14,"@ASIN",1,47,0,0,0
DATA 13,"@ATAN",1,47,0,0,0
DATA 12,"@ATAN2",1,47,1,52,-1
Page6Data:
DATA 51,"@AVG",0,63,5,69,0
DATA 52,"@COUNT",0,63,5,69,0
DATA 54,"@MAX",0,63,5,69,0
DATA 53,"@MIN",0,63,5,69,0
DATA 58,"@STD",0,63,5,69,0
DATA 50,"@SUM",0,63,5,69,0
DATA 57,"@VAR",0,63,5,69,0
DATA 62,"@DAVG",0,63,5,69,7,63,7,65,7,66,0
DATA 63,"@DCOUNT",0,63,5,69,7,63,7,65,7,66,0
DATA 65,"@DMAX",0,63,5,69,7,63,7,65,7,66,0
DATA 64,"@DMIN",0,63,5,69,7,63,7,65,7,66,0
DATA 67,"@DSTD",0,63,5,69,7,63,7,65,7,66,0
DATA 61,"@DSUM",0,63,5,69,7,63,7,65,7,66,0
DATA 66,"@DVAR",0,63,5,69,7,63,7,65,7,66,0
Page7Data:
DATA 59,"@IRR",14,24,11,23,11,24,0,0,0
DATA 56,"@NPV",14,22,11,23,11,37,0,0,0
DATA 26,"@PMT",14,22,14,24,14,26,0,0,0
DATA 27,"@PV",9,24,14,24,14,26,0,0,0
DATA 28,"@FV",9,24,14,24,14,26,0,0,0
DATA 85,"@RATE",9,26,9,25,14,25,0,0,-1
DATA 86,"@TERM",9,24,14,24,9,26,0,0,-1
DATA 87,"@CTERM",14,24,9,26,9,25,0,0,-1
DATA 88,"@SLN",14,28,14,29,14,30,0,0,-1
DATA 90,"@DDB",14,28,14,29,14,30,14,31,-1
DATA 89,"@SYD",14,28,14,29,14,30,14,31,-1
Page8Data:
DATA 22,"@TRUE",0,0,0,0,0,0,0
DATA 21,"@FALSE",0,0,0,0,0,0,0
DATA 29,"@IF",9,42,12,42,12,43,0
DATA 29,"@IF",9,43,12,42,12,43,0
DATA 02,"@ERR",0,0,0,0,0,0,0
DATA 01,"@NA",0,0,0,0,0,0,0
DATA 20,"@ISERR",9,46,0,0,0,0,0
DATA 20,"@ISERR",9,47,0,0,0,0,0
DATA 19,"@ISNA",9,47,0,0,0,0,0
DATA 19,"@ISNA",9,46,0,0,0,0,0
DATA 38,"@ISNUMBER",9,42,0,0,0,0,-1
DATA 38,"@ISNUMBER",12,42,0,0,0,0,-1
DATA 39,"@ISSTRING",12,42,0,0,0,0,-1
DATA 39,"@ISSTRING",9,42,0,0,0,0,-1
Page9Data:
DATA 69,"@COLS",0,82,7,86,0,0,0,0,-1
DATA 60,"@HLOOKUP",2,82,0,82,7,86,0,82,-1
DATA 68,"@INDEX",0,82,7,86,2,82,0,82,-1
DATA 70,"@ROWS",0,82,7,86,0,0,0,0,-1
DATA 55,"@VLOOKUP",2,82,0,82,7,86,1,82,-1
DATA 84,"@@(D89)",3,88,0,0,0,0,0,0,-1
DATA 78,"@CELL",4,88,0,4,0,0,0,0,-1
DATA 49,"@CELLPOINTER",5,88,0,4,0,0,0,0,-1
Page10Data:
DATA "123-Write version 2 demo worksheet Page 10"
DATA " "
DATA " This page is the second page of the 123-Write features index."
DATA " "
DATA "To return to the first index page, hit F5, then F3 and select PAGE_1."
DATA " "
DATA "Additional features of 123-Write are below. You can use the:"
DATA "F5 [GOTO] key, then the F3 key to select an area of interest.
DATA " "
DATA "Page 10 This page, Another example of String writes."
DATA " 11 Date and Time @ Functions."
DATA " 12 String handling @ Functions."
DATA " 13 The @Choose function, needs a special CALLing method."
DATA " 14 Examples of the 123-Write lCellMath routine."
DATA " 15 123-Write's lColFunction and lRowFunction routines."
DATA " 16 The lConstMath routine. Takes a cell and fixed number."
DATA " 17 Multicell math formulas. Simple math on multiple cells."
DATA " 18 Print control routines, range, borders, margins etc."
DATA " 19 Sort range controls, define and select keys."
DATA " 20 Spreadsheet cell linking, 1-2-3 Release 2.2 only."
Page11Data:
DATA 31,"@MONTH",14,62,0,0,0,0,0
DATA 30,"@DAY",14,62,0,0,0,0,0
DATA 32,"@YEAR",14,62,0,0,0,0,0
DATA 24,"@DATE",9,64,9,62,9,63,0
DATA 47,"@DATEVALUE",14,64,0,0,0,0,-1
DATA 35,"@HOUR",14,63,0,0,0,0,-1
DATA 36,"@MINUTE",14,63,0,0,0,0,-1
DATA 37,"@SECOND",14,63,0,0,0,0,-1
DATA 34,"@TIME",9,67,9,68,9,69,-1
DATA 48,"@TIMEVALUE",14,65,0,0,0,0,-1
DATA 25,"@NOW",0,0,0,0,0,0,0
Page12Data:
DATA "These","are","string","entries","in","seperate","cells."
DATA " This string is contained all in one cell."
DATA 45,"@CODE",8,82,0,0,0,0,-1 : REM all col J (9) row-85
DATA 44,"@CHAR",9,85,0,0,0,0,-1 : REM row-86
DATA 80,"@CLEAN",9,82,0,0,0,0,-1 : REM row-87
DATA 73,"@LOWER",8,82,0,0,0,0,-1 : REM row-88
DATA 72,"@UPPER",8,82,0,0,0,0,-1 : REM row-89
DATA 83,"@EXACT",9,88,9,89,0,0,-1 : REM row-90
DATA 83,"@EXACT",9,88,9,88,0,0,-1 : REM row-91
DATA 46,"@FIND",10,82,8,83,13,81,-1 : REM row-92
DATA 40,"@LENGTH",8,83,0,0,0,0,-1 : REM row-93
DATA 74,"@LEFT",8,83,9,92,0,0,-1 : REM row-94
DATA 43,"@MID",8,83,9,92,9,92,-1 : REM row-95
DATA 75,"@RIGHT",8,83,9,92,0,0,-1 : REM row-96
DATA 77,"@PROPER",8,83,0,0,0,0,-1 : REM row-97
DATA 79,"@TRIM",8,83,0,0,0,0,-1 : REM row-98
DATA 71,"@REPEAT",9,86,9,92,0,0,0,0,-1
DATA 76,"@REPLACE",9,98,9,91,9,93,9,87,-1
DATA 42,"@STRING",14,84,9,91,0,0,0,0,-1
DATA 41,"@VALUE",14,83,0,0,0,0,0,0,-1
DATA 82,"@N(O84)",14,83,14,83,0,0,0,0,-1
DATA 82,"@N(O85)",14,84,14,84,0,0,0,0,-1
DATA 81,"@S(O84)",14,83,14,83,0,0,0,0,-1
DATA 81,"@S(O85)",14,84,14,84,0,0,0,0,-1
Page13Data:
DATA "123-Write version 2 demo worksheet -- The @CHOOSE function. Page 13"
DATA " "
DATA "The @CHOOSE function requires a set of parameters different than any"
DATA "other Lotus 1-2-3 @Function. Where some @Functions take a single cell,"
DATA "a range or even mixed parameters, they all have a pretty rigid format."
DATA " "
DATA "@CHOOSE on the other hand is rather flexible. It takes an integer first,"
DATA "which represents which element of the list to select (Choice below) and"
DATA "a list of individual cells. Rather than set up a seperate routine for"
DATA "this one function, 123-Write is coded to use the second parameter of an"
DATA "integer structure (either a TYPE'd variable or an array) as the count"
DATA "of cells in the formula. The offset cell must be counted as part of the"
DATA "list. See the BASIC source code for how this call was set up. The cell"
DATA "count passed to the routine was 9, eight cells in the list, plus the"
DATA "offset cell."
DATA " "
DATA "Zero","One","Two","Three","Four","Five","Six","Seven"
DATA "Choice:"
DATA "You selected: "
Page14Data:
DATA "123-Write version 2 demo worksheet -- The lCellMath routine. Page 14"
DATA " "
DATA "The lCellMath routine does simple Quick Math on two cells."
DATA "In the call, you specify what two cells to operate on, and"
DATA "the operation to perform. The operations are: Add, Subtract"
DATA "Multiply, Divide, and raise to a power."
DATA ""
DATA "R28+S28:"
DATA "R29-S29:"
DATA "R30*S30:"
DATA "R31/S31:"
DATA "R32^S32:"
Page15Data:
DATA "@SUM(row)",1
DATA "@AVG(row)",2
DATA "@COUNT(row)",3
DATA "@MIN(row)",4
DATA "@MAX(row)",5
DATA "@STD(row)",6
DATA "@VAR(row)",7
DATA "@COLS(row)",8
DATA "@SUM(col)",1
DATA "@AVG(col)",2
DATA "@COUNT(col)",3
DATA "@MIN(col)",4
DATA "@MAX(col)",5
DATA "@STD(col)",6
DATA "@VAR(col)",7
DATA "@ROWS(col)",8
Page16Data:
DATA "123-Write version 2 demo worksheet--The lConstMath routine. Page 16"
DATA ""
DATA "lConstMath takes a fixed number and a cell reference and writes a"
DATA "simple math formula to the current cell. The operators you can"
DATA "use are Add, Subtract, Multiply, Divide and raise to a value."
DATA
DATA "If the operator is a negative number, the order of the math is"
DATA "reversed. For example, with a constant value of: "
DATA "Add P71 and const:"
DATA "Sub const from P72:"
DATA "Multiply P73 by const:"
DATA "Divide P74 and const:"
DATA "Raise P75 to const power:"
Page17Data:
DATA "123-Write version 2 -- The lMultiCellMath routine. Page 17"
DATA ""
DATA "lMultiCellMath use an integer structure to perform math on a series of"
DATA "cells. The array or TYPE'd variable needs to be filled in with the cell"
DATA "to operate on, (two integers, col and row) and the operation to perform."
DATA "The number of cells in the calculation is limited by Lotus's formula"
DATA "length maximum. The last operation code sent to 123-Write must be a"
DATA "zero to indicate the end of the formula."
DATA ""
DATA "The cells below were written using numeric values from other parts of"
DATA "this worksheet. Notice how the formula expands from left to right."
DATA "It is important to keep operator precedence in mind when coding too.
DATA ""
DATA 19,70,1,19,51,2,15,43,3,15,45,4,19,48,1,19,54,2,16,44,3,17,45,0
Page18Data:
DATA "123-Write version 2 -- The lPrint? Routines. Page 18"
DATA ""
DATA "123-Write allows you complete control over the printed output of your"
DATA "spreadsheets. The routines available, the Lotus defaults and the new"
DATA "settings, written from BASIC are:"
DATA ""
DATA " Lotus Current"
DATA "Routine Effect Default Setting"
DATA ""
DATA "lPrintRange Define print range none This page"
DATA "lPrintBorders Column & Row borders none Col A and Row 1"
DATA "lPrintMargins Page margins* 4-76-2-2-66 2-78-3-3-66"
DATA "lPrintSetup Printer Setup String none ESC-X-1"
DATA "lPrintTitle Header and Footer none 'Header'-'Footer'"
DATA ""
DATA "*The margins are defined as Left, Right, Top, Bottom, Page Length"
Page19Data:
DATA "123-Write version 2 -- The Sort Range Routines. Page 19"
DATA ""
DATA "123-Write allows you complete control over the sort range defined in"
DATA "your spreadsheet. Lotus defaults to no defined sort range, so that"
DATA "to build one in 123, you would have to include a macro to define the"
DATA "sort range, keys, ascending or descending order etc. The routines"
DATA "in 123-Write allow you to determine these settings in advance:"
DATA ""
DATA " Current"
DATA "Routine Effect Setting"
DATA ""
DATA "lSortRange Specifies the range to be sorted. P43..V50"
DATA "lSortKey Specifies the primary or secondary P = V43"
DATA " sort key column, & whether sort S = U43"
DATA " is ascending or descending. both ascnd"
DATA ""
DATA "The defined range is the table on Page 15. If you [GOTO] page 15,"
DATA "and issue a /Data Sort Go command, you'll see the results."
Page20Data:
DATA "123-Write version 2 -- The lLink Routine. Page 20"
DATA ""
DATA "123-Write allow you to define cells in your worksheets that will contain"
DATA "values from a second worksheet. This feature, spreadsheet linking, was"
DATA "not available in 1-2-3 releases before 2.2. Care should be taken before"
DATA "using the routine, to be sure the target system is at least release 2.2."
DATA ""
DATA "lLink requires that you specify a file and cell or range name in the same"
DATA "format as Lotus would use. Two left angle bracketts, the file name, two"
DATA "right angle brackets and the range name."
DATA ""
SUB ColFeed
'Just a routine to stay within a column, in a top down form.
CALL lDown(1)
CALL lLeft(1)
END SUB
SUB Page1
'==================================================================
'
' When a worksheet file is opened with lFileOpen, the cell pointer
' that 123-Write maintains is positioned at A1, which is column 0
' row 0.
'
' Next step is to write some string data to the first 'page' of the
' worksheet. A page in the default setup is 20 rows vertical and
' 8 cols horizontal, column A thru H, 0 thru 7. Each column is 9
' characters wide by default, so we can write strings of up to 72
' characters onto a page, or 'window'.
'
' Routines used to write to our first window are:
' lWriteStr and lLineFeed.
'
'==================================================================
CALL lSetLoc(0, 0) 'Overkill in this instance.
RESTORE Page1Data ' Same as above!
CALL WriteCol(20) 'Writes 20 rows of string data.
END SUB
SUB Page10
'=========================================================================
'
' Boy, this is boring, just writing a second menu page....
'
'=========================================================================
RESTORE Page10Data
CALL lSetLoc(Page10Col, Page10Row)
CALL WriteCol(19)
END SUB
SUB Page11
'=========================================================================
'
' More cell functions.... These deal with the date and time functions.
'
'=========================================================================
CALL lSetCellForm(fixed, 0)
CALL lSetLoc(Page11Col, Page11Row)
CALL lWriteStr("123-Write version 2 Date and Time @ Functions Page 11", errCode)
CALL lSetLoc(13, 62) 'Jump over to N63 and write..
CALL lWriteStr("Today's date:", errCode)
CALL lToday 'Writes the @Now function with date format.
CALL lDown(1)
CALL lLeft(2)
CALL lWriteStr("Current time:", errCode)
CALL lTimeNow 'Writes the @Now function with time format.
CALL lDown(1)
CALL lLeft(2)
a$ = DATE$
MID$(a$, 3, 1) = "/": MID$(a$, 6, 1) = "/"
IF MID$(a$, 7, 2) = "19" THEN
a$ = LEFT$(a$, 6) + RIGHT$(a$, 2)
END IF
CALL lWriteStr("Date string:", errCode)
CALL lWriteStr(CHR$(34) + a$, errCode) 'Right justify.
CALL lDown(1)
CALL lLeft(2)
a$ = TIME$
CALL lWriteStr("Time string:", errCode)
CALL lWriteStr(CHR$(34) + a$, errCode) 'Right justify.
CALL lSetLoc(Page11Col, Page11Row)
CALL lDown(2) 'set up for routine display.
RESTORE Page11Data
FOR i = 1 TO 10
READ f.fCode, a$, f.col1, f.row1, f.col2, f.row2, f.col3, f.row3, support
IF i = 9 THEN CALL lSetCellForm(fixed, 4)
CALL lWriteStr(CHR$(34) + a$ + ":", errCode)
IF support THEN
IF lVersion THEN
CALL lCellFunction(VARSEG(f), VARPTR(f))
ELSE
CALL lWriteStr("Not Avail", errCode)
END IF
ELSE
CALL lCellFunction(VARSEG(f), VARPTR(f))
END IF
CALL lDown(1)
CALL lLeft(2)
NEXT i
READ f.fCode, a$, f.col1, f.row1, f.col2, f.row2, f.col3, f.row3, support
CALL lSetCellForm(fixed, 2)
CALL lWriteStr(CHR$(34) + a$ + ":", errCode)
IF support THEN
IF lVersion THEN
CALL lCellFunction(VARSEG(f), VARPTR(f))
ELSE
CALL lWriteStr("Not Avail", errCode)
END IF
ELSE
CALL lCellFunction(VARSEG(f), VARPTR(f))
END IF
END SUB
SUB Page12
'=========================================================================
'
' Even more cell functions.... These deal with the string functions.
'
'=========================================================================
CALL lSetLoc(Page12Col, Page12Row)
CALL lWriteStr("123-Write version 2.0 Demonstarion Worksheet--String @Functions Page 12", errCode)
CALL ColFeed
CALL lDown(1)
FOR i = 1 TO 7
READ a$
CALL lWriteStr(a$, errCode)
NEXT
CALL lDown(1)
CALL lLeft(7)
READ a$
CALL lWriteStr(a$, errCode)
CALL lSetLoc(lCol("n"), 83)
CALL lWriteStr(CHR$(34) + "A string:", errCode)
CALL lWriteStr(CHR$(34) + "123.456", errCode)
CALL ColFeed
CALL lLeft(1)
CALL lSetCellForm(fixed, 3)
CALL lWriteStr(CHR$(34) + "A real #:", errCode)
CALL lWriteNum(123.456#, errCode)
CALL lSetLoc(lCol("I"), 85)
FOR i = 1 TO 14
READ f.fCode, a$, f.col1, f.row1, f.col2, f.row2, f.col3, f.row3, support
CALL lWriteStr(CHR$(34) + a$ + ":", errCode)
IF support THEN
IF lVersion THEN
CALL lCellFunction(VARSEG(f), VARPTR(f))
ELSE
CALL lWriteStr("Not Avail", errCode)
END IF
ELSE
CALL lCellFunction(VARSEG(f), VARPTR(f))
END IF
CALL lDown(1)
CALL lLeft(2)
NEXT i
CALL lSetLoc(Page12Col + 4, Page12Row + 5)
FOR i = 1 TO 8
READ f.fCode, a$, f.col1, f.row1, f.col2, f.row2, f.col3, f.row3, f.col4, f.row4, support
CALL lWriteStr(CHR$(34) + a$ + ":", errCode)
IF support THEN
IF lVersion THEN
CALL lCellFunction(VARSEG(f), VARPTR(f))
ELSE
CALL lWriteStr("Not Avail", errCode)
END IF
ELSE
CALL lCellFunction(VARSEG(f), VARPTR(f))
END IF
CALL lDown(1)
CALL lLeft(2)
NEXT i
END SUB
SUB Page13
'=========================================================================
'
' Something unique, the @choose function. This guy requires that the
' number of cells in the 'list' to choose from be specified. Note that
' in version 1a, @choose expects all numeric data to work with... This
' example uses strings, and thus the 1a 1-2-3 will always return 0 as
' as a result....
'
'=========================================================================
CALL lSetLoc(Page13Col, Page13Row)
CALL lSetCellForm(fixed, 0)
CALL WriteCol(16)
FOR i = 1 TO 8
READ a$
CALL lWriteStr(a$, errCode)
NEXT
CALL lLineFeed
CALL WriteCol(2)
CALL lSetLoc(1, 137) 'B138 has the offset, must be 0 to 7
a = Rand(0, 7)
CALL lWriteInt(a, errCode) 'Write the offset.
'========================================================================
'
' The array (could use a TYPE'd variable also) has to be:
'
' ((# of cells in list) * 2) + 4 elements in size.
'
' In this case we have 8 cells in the list, so DIM is 1 to 20
'
'========================================================================
REDIM temp%(1 TO 20)
temp%(1) = 18 'The @ function desired, @CHOOSE is 18
temp%(2) = 9 'Number of elements (cells)+1 for the offset cell.
temp%(3) = 1 'The offset into the list to choose. In
temp%(4) = 137 'cell B138
row = 136 'The list data is across row 137
col = 0 'from column A through column H
FOR i = 5 TO 20 STEP 2 'Fill the balance of the array:
temp%(i) = col 'Col 0 thru 7 in elements 5,7,9,11,13,15,17,19
temp%(i + 1) = row 'Constant row in elements 6,8,10,12,14,16,18,20
col = col + 1
NEXT
CALL lSetLoc(2, 138) 'The @Choose function goes into C139
CALL lCellFunction(VARSEG(temp%(1)), VARPTR(temp%(1)))
ERASE temp%
END SUB
SUB Page14
'=========================================================================
'
' Simple math functions..
'
'=========================================================================
CALL lSetLoc(Page14Col, Page14Row)
RESTORE Page14Data
CALL WriteCol(7)
col = 17 'Set to cell R28
row = 27
CALL lSetLoc(col, row) '<---- Set the location.
CALL lSetCellForm(fixed, 2) ' |
' |
FOR i = 1 TO 5 '
CALL lWriteInt(i, errCode) 'add a column +1
CALL lWriteInt(i + 1, errCode) 'add a column +1
READ a$ '
CALL lWriteStr(CHR$(34) + a$ + ":", errCode) 'add a column +1
CALL lCellMath(col, row, col + 1, row, i) 'add a column +1
CALL lDown(1) ' ===
CALL lLeft(4) '<-- Return -- 4
row = row + 1
NEXT
END SUB
SUB Page15
CALL lSetLoc(Page15Col, Page15Row)
CALL lWriteStr("123-Write version 2.0 lColFunction & lRowFunction Page 15", errCode)
CALL ColFeed
CALL lDown(1)
RESTORE Page15Data
FOR row = 1 TO 8
FOR col = 1 TO 5
CALL lWriteInt(i, errCode)
i = i + 1
NEXT
READ a$, operation
CALL lWriteStr(CHR$(34) + a$ + ":", errCode)
IF operation < 8 OR lVersion THEN
CALL lRowFunction(Page15Col, Page15Col + 4, operation)
ELSE
CALL lWriteStr("Not supported in 1a", errCode)
END IF
CALL lDown(1)
CALL lLeft(7)
NEXT
CALL lGetLoc(col, lastRow) 'Cell pointer is one row
lastRow = lastRow - 1 'below the last row of data.
FOR col = 1 TO 7
CALL lWriteStr("\=", errCode)
NEXT
CALL lDown(1)
CALL lLeft(7)
FOR col = 1 TO 8
READ a$, operation
CALL lWriteStr(CHR$(34) + a$ + ":", errCode)
CALL lRight(1)
IF operation < 8 OR lVersion THEN
CALL lColFunction(lastRow - 7, lastRow, operation)
CALL lColFunction(lastRow - 7, lastRow, operation)
CALL lColFunction(lastRow - 7, lastRow, operation)
ELSE
CALL lWriteStr("Not supported in 1a", errCode)
CALL lWriteStr("Not supported in 1a", errCode)
CALL lWriteStr("Not supported in 1a", errCode)
END IF
CALL lDown(1)
CALL lLeft(5)
NEXT
END SUB
SUB Page16
CALL lSetLoc(Page16Col, Page16Row)
RESTORE Page16Data
CALL WriteCol(8)
constant = Rand(1, 5)
CALL lWriteInt(constant, errCode)
CALL lRight(3)
CALL lWriteStr(" Positive Negative", errCode)
constant# = CDBL(constant)
CALL ColFeed
CALL lLeft(4)
CALL lDown(1)
row = 70
FOR i = 1 TO 5
CALL lWriteInt(i, errCode)
READ a$
CALL lWriteStr(a$, errCode)
CALL lRight(2)
CALL lConstMath(lCol("P"), row, constant#, i)
CALL lConstMath(lCol("P"), row, constant#, -i)
row = row + 1
CALL lDown(1)
CALL lLeft(6)
NEXT
END SUB
SUB Page17
'========================================================================
'
' This routine is called after the worksheet file was closed,
' then re-opened using lFileAppend. When a spreadsheet is
' opened in "Append" mode, the cell pointer is at the {end}{home}
' position of the opened file. Need to set it to prevent writing
' over any data that may be there.
'
'========================================================================
DIM mm(1 TO 8) AS MultiMathType
CALL lGetLoc(oldEndCol, oldEndRow)
PRINT "Just closed and reopened the spreadsheet. The"
PRINT "End-Home (size) of the spreadsheet was Cell ";
PRINT CHR$(oldEndCol + 65); LTRIM$(STR$(oldEndRow + 1))
PRINT "In case you're curious."
CALL lSetLoc(Page17Col, Page17Row)
RESTORE Page17Data
CALL WriteCol(13)
CALL lDown(1)
'========================================================================
'
' What I want to demonstrate here is how a formula can be built up
' by adding data on to the existing structure.
'
'========================================================================
READ mm(1).col, mm(1).row, mm(1).opr
FOR i = 2 TO 8
READ mm(i).col, mm(i).row, mm(i).opr
hold = mm(i).opr
mm(i).opr = 0
CALL lMultiCellMath(VARSEG(mm(1)), VARPTR(mm(1)))
mm(i).opr = hold
NEXT
END SUB
SUB Page18
CALL lSetLoc(Page18Col, Page18Row)
RESTORE Page18Data
CALL WriteCol(16)
CALL lPrintRange(Page18Col, Page18Row, Page18Col + 6, Page18Row + 19)
CALL lPrintBorders(0, 0, 0, 0, 0, 0, 0, 0)
CALL lPrintMargins(2, 78, 3, 3, 66)
CALL lPrintSetup("\027\088\049")
CALL lPrintTitle("Header", -1)
CALL lPrintTitle("Footer", 0)
END SUB
SUB Page19
CALL lSetLoc(Page19Col, Page19Row)
RESTORE Page19Data
CALL WriteCol(18)
CALL lSortRange(15, 42, 21, 49)
CALL lSortKey(-1, 21, 42, 21, 49, -1)
CALL lSortKey(0, 20, 42, 20, 49, -1)
END SUB
SUB Page2
'==================================================================
'
' Page two will display the format options available
' when writing a file from 123-Write.
'
' lSetLoc is used to get to the top of page 2. lWriteInt is used
' to write integer values to the cells, and lSetCellForm is called
' to change the display format with each cell written. lRight is
' used as a lazy method to move to column I.
'
' Note that some of the displays are going to require more than the
' default 9 characters in the cells. lSetCol is used to widen
' column M to 11, N to 12 and O to 13. Column P is not going to
' visible on screen in Lotus.
'
'==================================================================
newWidth = 11 'Width setting of the column.
FOR i = lCol%("M") TO lCol%("o") 'Note case isn't significant.
CALL lSetCol(i, newWidth) 'desired col, desired width.
newWidth = newWidth + 1 'next col, 1 greater than current.
NEXT
RESTORE Page2Data
CALL lSetLoc(Page2Col, Page2Row) 'Position cell pointer for first write.
READ a$
CALL lWriteStr(a$, errCode) 'print header line
IF errCode THEN ERROR 255
number = 1 'what integer we're going to write
FOR row = 1 TO 5 ' "Normal" formats.
CALL lLineFeed 'now at cell A?
CALL lRight(8) 'move to I? (are other ways, but ..)
READ a$ 'read & write the description
CALL lWriteStr(a$, errCode) ' of each row
FOR col = 0 TO 5
CALL lSetCellForm(row, col) 'row equals the format option &
CALL lWriteInt(number, errCode) 'col is the # of decimal places
IF errCode THEN ERROR 255
number = number + 1
NEXT
NEXT
CALL lLineFeed 'now at cell A?
CALL lRight(8) 'move to I?
FOR i = 0 TO 6 'Slip in a ===== page break.
CALL lWriteStr("\=", errCode) 'Note that the repeating
NEXT 'character label prefix is
'specified. Over-rides the
'123-Write default.
'==================================================================
'
' At this point the cell pointer is one column to the right, on the same
' row as, the last cell written. Some of the "special" formats take a
' little more work (planning) to get them to get them to look 'nice'.
'
' So, because one column to the left of the point we're at now is
' 13 characters wide, we'll use it to write out the special format options.
' Lot of jumping here so see if you can follow the bouncing cursor, err
' cell pointer....
'
'==================================================================
CALL lLeft(5) 'to O then N then M
CALL lDown(2) 'Skip a couple of lines....
CALL lWriteStr("Special Formats:", errCode) 'What we're showing
IF errCode THEN ERROR 255
CALL lRight(1) 'Add a column then move up a line
CALL lUp(1)
IF lVersion THEN maxForm = 12 ELSE maxForm = 5
FOR format = 0 TO maxForm 'All but "default"
CALL lSetCellForm(1, 0) 'Fixed, 0 decimals to display
CALL lWriteInt(format, errCode) 'the 'Special' cell format number.
IF errCode THEN ERROR 255
READ a$
CALL lWriteStr(a$, errCode) 'What format we're showing
CALL lSetCellForm(6, format) 'Set cell format to Special, 0 thru
' maxForm (maximum special formats)
CALL lWriteNum(RND * 10, errCode) 'Throw a number into the cell
CALL lLeft(3) 'Run back to the correct column
CALL lDown(1) ' and drop down a line.
NEXT
'=========================================================================
'
' OK, that should give us every cell format under the sun.
'
'=========================================================================
END SUB
SUB Page20
CALL lSetLoc(Page20Col, Page20Row)
RESTORE Page20Data
CALL WriteCol(11)
a$ = "CALL lLink(" + CHR$(34) + "<<filename>>Total" + CHR$(34) + ")"
CALL lWriteStr(a$, errCode)
END SUB
SUB Page3
'=========================================================================
'
' Page three shows the date and time routines, and the formats available.
' Some formats will need need wide columns, so we'll move to column P
' and use that area.
'
'=========================================================================
page3col = lCol%("P")
page3row = 0
CALL lSetLoc(page3col, page3row)
CALL lSetCol(page3col + 4, 11)
CALL lSetCol(page3col + 5, 13)
CALL lWriteStr("123-Write version 2 demo worksheet Page 3", errCode)
IF errCode THEN ERROR 255
'=========================================================================
'
' Another method of moving to a defined place, without left right up
' down etc... which is a starting place for yet another loop!
'
'=========================================================================
RESTORE Page3Data
protected = 0 'will turn individual cell protection off & on.
FOR i = 1 TO 5
CALL lSetLoc(page3col, (page3row + 1 + i)) 'Set the cell pointer
READ a$ 'Read and write the
CALL lWriteStr(a$, errCode) ' description label.
IF errCode THEN ERROR 255
CALL lSetLoc(page3col + 4, (page3row + 1 + i))
CALL lDate(DATE$) 'Writes the current date &
CALL lTime(TIME$) 'time in the default
CALL lSetDateForm(i, protected) 'formats. Then changes the
CALL lSetTimeForm(i, protected) 'cell formats & toggles the
protected = NOT protected 'cell protection.
NEXT
'do date format 5 by itself, as there is no time format 5.
CALL lSetLoc(page3col, (page3row + 1 + i))
READ a$
CALL lWriteStr(a$, errCode)
IF errCode THEN ERROR 255
CALL lSetLoc(page3col + 4, page3row + 1 + i)
CALL lDate(DATE$)
'Skip a couple of rows, I have no idea where I am now. But it's
'a starting place.
CALL lSetLoc(page3col, (page3row + 3 + i))
CALL lWriteStr("Setting of a date format and time format has no effect on other", errCode)
ColFeed
CALL lWriteStr("cells written with lWriteNum, lWriteInt or lWriteStr. It's a", errCode)
ColFeed
CALL lWriteStr("convience to set it for calls to the lDate, lTime, lTimeNow and", errCode)
ColFeed
CALL lWriteStr("lToday routines. lDate & lTime were used above, using the sys-", errCode)
ColFeed
CALL lWriteStr("tem date and time. Below are the lToday and lTimeNow routines.", errCode)
ColFeed
CALL lDown(2)
CALL lSetDateForm(4, 1)
CALL lWriteStr("lToday routine:", errCode)
CALL lRight(2)
CALL lToday
CALL lDown(1)
CALL lLeft(4)
CALL lSetTimeForm(3, 1)
CALL lWriteStr("lTimeNow routine:", errCode)
CALL lRight(2)
CALL lTimeNow
CALL lDown(1)
CALL lLeft(4)
CALL lWriteStr("Hit F9 now" + STRING$(17, "-") + "^", errCode)
END SUB
SUB Page4
'=========================================================================
'
' Got a little carried away with page 3....
'
' What to do with page 4? Well, let's start work on the Boolean functions.
' The manual page for lBoolean should be near by, I know mine is... Having
' it handy will aid in tracing along.....
'
' Old hat to start. We'll use A21 as the upper left corner of page 4, and
' we need to set the cell format for numeric stuff to what we want. Have
' no idea what it currently is, it's whatever the last special format we
' displayed??? Will use fixed, 3.
'
'=========================================================================
CALL lSetCellForm(fixed, 3)
CALL lSetLoc(0, 20)
CALL lWriteStr("123-Write version 2 boolean comparison examples. Page 4", errCode)
CALL lLineFeed
CALL lLineFeed
CALL lWriteStr("Data:", errCode) 'Just write a series
FOR i = 0 TO 6: CALL lWriteInt(i, errCode): NEXT 'of integers for data
CALL lLineFeed 'Skipping a line. The left bound
CALL lLineFeed 'of this page is col A, lLinefeed
'will suffice
CALL lWriteStr("B23=C23:", errCode)
CALL lBoolean(1, 22, 2, 22, 1) 'operation=1, equal?
CALL lRight(1)
CALL lWriteStr("B23=B24:", errCode)
CALL lBoolean(1, 22, 1, 23, 1) 'operation=1, equal?
CALL lWriteStr("<---Equality", errCode)
CALL lLineFeed
CALL lWriteStr("B23<>C23:", errCode)
CALL lBoolean(1, 22, 2, 22, 2) 'operation=2, not equal?
CALL lRight(1)
CALL lWriteStr("B23<>B24:", errCode)
CALL lBoolean(1, 22, 1, 23, 2) 'operation=2, not equal?
CALL lWriteStr("<--Not equal", errCode)
CALL lLineFeed
CALL lWriteStr("B23<=C23:", errCode)
CALL lBoolean(1, 22, 2, 22, 3) 'operation=3, less than
CALL lRight(1) ' or equal?
CALL lWriteStr("C23<=B23:", errCode)
CALL lBoolean(2, 22, 1, 22, 3)
CALL lWriteStr("<--Less than or equal", errCode)
CALL lLineFeed
CALL lWriteStr("B23>=C23:", errCode)
CALL lBoolean(1, 22, 2, 22, 4) 'operation=4, greater than
CALL lRight(1) ' or equal?
CALL lWriteStr("C23>=B23:", errCode)
CALL lBoolean(2, 22, 1, 22, 4)
CALL lWriteStr("<--Greater than or equal", errCode)
CALL lLineFeed
CALL lWriteStr("B23<C23:", errCode)
CALL lBoolean(1, 22, 2, 22, 5) 'operation=5, less than?
CALL lRight(1)
CALL lWriteStr("C23<C23:", errCode) 'Note that this does
CALL lBoolean(2, 22, 2, 22, 5) 'not give a "CIRC" error.
CALL lWriteStr("<--Less than", errCode) 'which I find odd.....
CALL lLineFeed
CALL lWriteStr("B23>C23:", errCode)
CALL lBoolean(1, 22, 2, 22, 6) 'operation=6, greater than?
CALL lRight(1)
CALL lWriteStr("C23>B23:", errCode)
CALL lBoolean(2, 22, 1, 22, 6)
CALL lWriteStr("<--Greater than", errCode)
CALL lLineFeed
CALL lWriteStr("#AND# :", errCode) 'operation=7, AND
CALL lBoolean(1, 22, 2, 22, 7) 'B23 and C23 (0 and 1) = 0
CALL lBoolean(2, 22, 3, 22, 7) 'C23 and D23 (1 and 2) = 1
CALL lBoolean(1, 22, 1, 23, 7) 'B23 and B24 (0 and 0) = 0
CALL lBoolean(3, 22, 3, 23, 7) 'D23 and D24 (2 and 0) = 0
CALL lWriteStr("Both cells must be non 0", errCode)
CALL lLineFeed
CALL lWriteStr("#OR# :", errCode) 'operation=8, OR
CALL lBoolean(1, 22, 2, 22, 8) 'B23 and C23 (0 or 1) = 1
CALL lBoolean(2, 22, 3, 22, 8) 'C23 and D23 (1 or 2) = 1
CALL lBoolean(1, 22, 1, 23, 8) 'B23 and B24 (0 or 0) = 0
CALL lBoolean(3, 22, 3, 23, 8) 'D23 and D24 (2 or 0) = 1
CALL lWriteStr("One cell must be non 0", errCode)
CALL lLineFeed
CALL lWriteStr("#NOT# :", errCode) 'operation=9, NOT 1 operator.
CALL lBoolean(1, 22, 0, 0, 9) 'B23 (not 0) = 1
CALL lBoolean(2, 22, 0, 0, 9) 'C23 (not 1) = 0
CALL lBoolean(3, 22, 0, 0, 9) 'D23 (not 2) = 0
CALL lBoolean(4, 22, 0, 0, 9) 'E23 (not 3) = 0
CALL lWriteStr("If cell is 0, returns 1", errCode)
CALL lLineFeed
CALL lLineFeed
CALL lWriteStr("Note that Lotus uses 1 to indicate a TRUE condition,", errCode)
CALL lLineFeed
CALL lWriteStr("unlike BASIC which uses a -1 (a true NOT 0, 0 being", errCode)
CALL lLineFeed
CALL lWriteStr("false?) Also the AND, OR and NOT operators are not", errCode)
CALL lLineFeed
CALL lWriteStr("bitwise operators, they just test for zero conditions.", errCode)
END SUB
SUB Page5
'=========================================================================
'
' What's next? lCellFunction! Let's get the monster out of the way.
'
' First, remember seeing a TYPE at the start of the program? If not,
' refresh yourself on it, cause that's what we're going to use. Also
' will slip in a column of numbers to work on over in column Z
'
'=========================================================================
CALL lSetLoc(Page5Col, Page5Row) 'Column is A so...
CALL lWriteStr("123-Write ver 2 General, Logarithmic & Trigonomteric @Functions: Pg 5", errCode)
CALL lLineFeed 'A simple method for skipping
CALL lLineFeed 'a line.
CALL lWriteStr("DATA:", errCode)
CALL lSetCellForm(fixed, zero) 'what's zero equate to?
CALL lWriteInt(11, errCode) 'Cell B43
CALL lWriteInt(3, errCode) 'Cell C43
CALL lSetCellForm(fixed, 4)
a# = CDBL(Rand(1, 8) * 123.45678#) 'a real number to work with
CALL lWriteNum(a#, errCode) 'in D43
CALL lLineFeed
CALL lLineFeed
CALL lGetLoc(col, startRow) 'Save row for a millisecond....
CALL lSetCellForm(fixed, 4)
RESTORE Page5Data
FOR i = 1 TO 9 'Support, if non-zero indicates
'a release 2.0+ @function....
READ f.fCode, a$, f.col1, f.row1, f.col2, f.row2, support
CALL lWriteStr(CHR$(34) + a$ + ":", errCode)
IF support THEN
IF lVersion THEN 'embedding the address calc in the call,
CALL lCellFunction(VARSEG(f), VARPTR(f)) 'cause I'm a chicken.
ELSE
CALL lWriteStr("Not Avail", errCode) 'Not supported in 1a.
END IF
ELSE
CALL lCellFunction(VARSEG(f), VARPTR(f)) 'All releases.
END IF
CALL lLineFeed
NEXT
CALL lSetLoc(3, startRow) 'Do trig items down Col D
FOR i = 1 TO 8
READ f.fCode, a$, f.col1, f.row1, f.col2, f.row2, support
CALL lWriteStr(CHR$(34) + a$ + ":", errCode)
IF support THEN
IF lVersion THEN
CALL lCellFunction(VARSEG(f), VARPTR(f))
ELSE
CALL lWriteStr("Not Avail", errCode)
END IF
ELSE
CALL lCellFunction(VARSEG(f), VARPTR(f))
END IF
CALL lDown(1)
CALL lLeft(2)
NEXT
END SUB
SUB Page6
'=========================================================================
'
' Page 6 is the statistical and database statistical page.
'
'=========================================================================
CALL lSetLoc(Page6Col, Page6Row)
CALL lWriteStr("123-Write ver 2 Statistical and Database Statistical @Functions: Pg 6", errCode)
CALL lLineFeed
CALL lLineFeed
FOR i = 0 TO 5
CALL lWriteStr("WEEK" + STR$(i), errCode)
NEXT
CALL lWriteStr("Offset:", errCode)
CALL ColFeed
CALL lRight(1)
CALL lWriteInt(0, errCode)
CALL ColFeed
CALL lLeft(1)
CALL lWriteStr("Criteria Range:", errCode)
CALL ColFeed
CALL lRight(1)
CALL lWriteStr("WEEK 0", errCode)
CALL lLineFeed
CALL lUp(3)
FOR row = 63 TO 69
FOR col = 0 TO 5
a = Rand(1, 15)
b = Rand(1, 15)
a# = CDBL(a + (a / b))
CALL lWriteNum(a#, errCode)
NEXT col
CALL lLineFeed
NEXT
CALL lLineFeed
CALL lWriteStr("Statistical:", errCode)
CALL lRight(2)
CALL lWriteStr("Database Statistical:", errCode)
CALL lLineFeed
CALL lLineFeed
CALL lGetLoc(col, startRow) 'Save row for a bit
CALL lSetCellForm(fixed, 4)
RESTORE Page6Data
FOR i = 1 TO 7
READ f.fCode, a$, f.col1, f.row1, f.col2, f.row2, support
CALL lWriteStr(CHR$(34) + a$ + ":", errCode)
IF support THEN
IF lVersion THEN
CALL lCellFunction(VARSEG(f), VARPTR(f))
ELSE
CALL lWriteStr("Not Avail", errCode)
END IF
ELSE
CALL lCellFunction(VARSEG(f), VARPTR(f))
END IF
CALL lLineFeed
NEXT
CALL lSetLoc(3, startRow) 'Do DB items down Col D
FOR i = 1 TO 7
READ f.fCode, a$, f.col1, f.row1, f.col2, f.row2, f.col3, f.row3, f.col4, f.row4, f.col5, f.row5, support
CALL lWriteStr(CHR$(34) + a$ + ":", errCode)
IF support THEN
IF lVersion THEN
CALL lCellFunction(VARSEG(f), VARPTR(f))
ELSE
CALL lWriteStr("Not Avail", errCode)
END IF
ELSE
CALL lCellFunction(VARSEG(f), VARPTR(f))
END IF
CALL lDown(1)
CALL lLeft(2)
NEXT
END SUB
SUB Page7
'=========================================================================
'
' Page 7 will be the Financial and Accounting functions. Starts in I20
'
'=========================================================================
CALL lSetLoc(Page7Col, Page7Row)
CALL lWriteStr("123-Write ver 2 Financial and Accounting @Functions: Page 7", errCode)
CALL ColFeed
CALL ColFeed
CALL lRight(4)
CALL lWriteStr("Cash Flows", errCode)
CALL lRight(1)
CALL lWriteStr("Principal:", errCode)
CALL ColFeed
CALL lWriteStr("Interest:", errCode)
CALL ColFeed
CALL lWriteStr("Monthly:", errCode)
CALL ColFeed
CALL lWriteStr("Term Years:", errCode)
CALL ColFeed
CALL lWriteStr("Term Month:", errCode)
CALL ColFeed
CALL lDown(1)
CALL lWriteStr("Cost:", errCode)
CALL ColFeed
CALL lWriteStr("Salvage:", errCode)
CALL ColFeed
CALL lWriteStr("Life:", errCode)
CALL ColFeed
CALL lWriteStr("Period:", errCode)
CALL lSetLoc(Page7Col + 6, Page7Row + 2)
CALL lSetCellForm(currcy, 2)
CALL lWriteNum(CDBL(Rand(1, 10000)), errCode)
CALL ColFeed
CALL lSetCellForm(percent, 2)
interest# = CDBL(Rand(1, 12) / 100#)
CALL lWriteNum(interest#, errCode)
CALL ColFeed
CALL lWriteNum(interest# / 12#, errCode)
CALL ColFeed
CALL lSetCellForm(comma, 2)
a = Rand(1, 30)
CALL lWriteInt(a, errCode)
CALL ColFeed
CALL lWriteInt(a * 12, errCode)
CALL ColFeed
CALL lDown(1)
cost# = CDBL(Rand(1, 32760))
salvage# = CDBL(Rand(1, 1000))
IF cost# < salvage# THEN SWAP cost#, salvage#
CALL lWriteNum(cost#, errCode)
CALL ColFeed
CALL lWriteNum(salvage#, errCode)
CALL ColFeed
life = Rand(10, 20)
CALL lWriteInt(life, errCode)
CALL ColFeed
period = Rand(1, life)
CALL lWriteInt(period, errCode)
CALL lSetLoc(Page7Col, Page7Row)
CALL lRight(3)
CALL lDown(3)
flow# = CDBL(Rand(1, 9) * 123#)
incr# = CDBL(Rand(1, 9) * 12.3#)
FOR i = 1 TO 15
CALL lWriteNum(flow#, errCode)
flow# = flow# + incr#
CALL ColFeed
NEXT
CALL lSetLoc(Page7Col, Page7Row)
CALL lDown(2)
RESTORE Page7Data
FOR i = 1 TO 11
READ f.fCode, a$, f.col1, f.row1, f.col2, f.row2, f.col3, f.row3, f.col4, f.row4, support
CALL lWriteStr(CHR$(34) + a$ + ":", errCode)
IF support THEN
IF lVersion THEN
CALL lCellFunction(VARSEG(f), VARPTR(f))
ELSE
CALL lWriteStr("Not Avail", errCode)
END IF
ELSE
CALL lCellFunction(VARSEG(f), VARPTR(f))
END IF
CALL lDown(1)
CALL lLeft(2)
NEXT i
END SUB
SUB Page8
'=========================================================================
'
' Page 8 will be the logical functions and the @ERR and @NA functions.
'
'=========================================================================
CALL lSetLoc(Page8Col, Page8Row)
CALL lWriteStr("123-Write version 2 Logical @ Functions Page 8", errCode)
CALL ColFeed
CALL ColFeed 'Skipping a line in a column.
CALL lRight(5)
CALL lWriteStr("That's true!", errCode)
CALL ColFeed
CALL lWriteStr("That's false!", errCode)
CALL lSetLoc(Page8Col, Page8Row)
CALL lDown(2)
RESTORE Page8Data
FOR i = 1 TO 14
READ f.fCode, a$, f.col1, f.row1, f.col2, f.row2, f.col3, f.row3, support
CALL lWriteStr(CHR$(34) + a$ + ":", errCode)
IF support THEN
IF lVersion THEN
CALL lCellFunction(VARSEG(f), VARPTR(f))
ELSE
CALL lWriteStr("Not Avail", errCode)
END IF
ELSE
CALL lCellFunction(VARSEG(f), VARPTR(f))
END IF
CALL lDown(1)
CALL lLeft(2)
NEXT i
END SUB
SUB Page9
'=========================================================================
'
' Page 9 will be range functions.
'
'=========================================================================
CALL lSetLoc(Page9Col, Page9Row)
CALL lWriteStr("123-Write version 2 Range @ Functions Page 9", errCode)
CALL lLeft(1)
CALL lDown(2)
i = 1
FOR row = 1 TO 5
FOR col = 0 TO 7
CALL lWriteInt(i, errCode)
i = i + 1
NEXT
CALL lLineFeed
NEXT
RESTORE Page9Data
CALL lLineFeed
CALL lWriteStr("A target cell as a string:", errCode)
CALL lRight(2)
CALL lWriteStr("A5", errCode)
CALL lWriteStr("PREFIX", errCode)
CALL lWriteStr("CONTENTS", errCode)
CALL lLineFeed
CALL lLineFeed
FOR i = 1 TO 8
READ f.fCode, a$, f.col1, f.row1, f.col2, f.row2, f.col3, f.row3, f.col4, f.row4, support
CALL lWriteStr(CHR$(34) + a$ + ":", errCode)
IF support THEN
IF lVersion THEN
CALL lCellFunction(VARSEG(f), VARPTR(f))
ELSE
CALL lWriteStr("Not Avail", errCode)
END IF
ELSE
CALL lCellFunction(VARSEG(f), VARPTR(f))
END IF
CALL lDown(1)
CALL lLeft(2)
NEXT i
END SUB
FUNCTION Rand% (lowerbound, upperbound)
'Yes sir, straight from the on-line help window:
Rand% = INT((upperbound - lowerbound + 1) * RND + lowerbound)
END FUNCTION
SUB WriteCol (count)
FOR i = 1 TO count
READ a$
CALL lWriteStr(a$, errCode)
IF errCode THEN ERROR 255
CALL ColFeed
NEXT
END SUB
SUB WriteRanges
page3col = lCol%("P")
page3row = 0
CALL lRange("PAGE_1", Page1Col, Page1Row, Page1Col + 7, Page1Row + 19)
CALL lRange("PAGE_2", Page2Col, Page2Row, Page2Col, Page2Row)
CALL lRange("PAGE_3", page3col, page3row, page3col, page3row)
CALL lRange("PAGE_4", 0, 20, 7, 39)
CALL lRange("PAGE_5", Page5Col, Page5Row, Page5Col, Page5Row)
CALL lRange("PAGE_6", Page6Col, Page6Row, Page6Col, Page6Row)
CALL lRange("PAGE_7", Page7Col, Page7Row, Page7Col, Page7Row)
CALL lRange("PAGE_8", Page8Col, Page8Row, Page8Col, Page8Row)
CALL lRange("PAGE_9", Page9Col, Page9Row, Page9Col, Page9Row)
CALL lRange("PAGE_10", Page10Col, Page10Row, Page10Col + 7, Page10Row + 19)
CALL lRange("PAGE_11", Page11Col, Page11Row, Page11Col, Page11Row)
CALL lRange("PAGE_12", Page12Col, Page12Row, Page12Col, Page12Row)
CALL lRange("PAGE_13", Page13Col, Page13Row, Page13Col, Page13Row)
CALL lRange("PAGE_14", Page14Col, Page14Row, Page14Col, Page14Row)
CALL lRange("PAGE_15", Page15Col, Page15Row, Page15Col, Page15Row)
CALL lRange("PAGE_16", Page16Col, Page16Row, Page16Col, Page16Row)
CALL lRange("PAGE_17", Page17Col, Page17Row, Page17Col, Page17Row)
CALL lRange("PAGE_18", Page18Col, Page18Row, Page18Col, Page18Row)
CALL lRange("PAGE_19", Page19Col, Page19Row, Page19Col, Page19Row)
CALL lRange("PAGE_20", Page20Col, Page20Row, Page20Col, Page20Row)
END SUB